const path = require('path');
const Ps = require('ee-core/ps');
const Log = require('ee-core/log');
const Electron = require('ee-core/electron');
const CoreWindow = require('ee-core/electron/window');
const Conf = require('ee-core/config');
const EE = require('ee-core/ee');
const AutoLaunch = require('auto-launch');

/**
 * 开机自启动
 * @class
 */
class AutoLaunchAddon {

  constructor() {
    this.tray = null;
  }

  /**
   * 创建开机自启动
   */
  create () {
    Log.info('[addon:autoLaunch] load');
    var minecraftAutoLauncher = new AutoLaunch({
      name: 'PublishClient',
      //path: '/Applications/PublishClient.app',
    });
    
    // minecraftAutoLauncher.enable();
    
    //minecraftAutoLauncher.disable();
    
    minecraftAutoLauncher.isEnabled()
    .then(function(isEnabled){
      if(isEnabled){
          return;
      }
      minecraftAutoLauncher.enable();
    })
    .catch(function(err){
        // handle error
    });
  }
}

AutoLaunchAddon.toString = () => '[class AutoLaunchAddon]';
module.exports = AutoLaunchAddon;